class eventEmit {
    constructor() {
        _events = []
    }
    on = (evt, fn) => {
        (this._events[evt] || (this._events[evt] = [])).push(fn)
    }
    once = (evt, fn) => {
        function exeFn() {
            fn.apply(this)
            this.off(evt, exeFn)
        }
        this.on(evn, exeFn)
    }
    eimt = (evt, args) => {
        if (!this._events[evt]) return false
        const fns = this._events[evt]
        fns.forEach(fn => {
            fn.apply(this, ...args)
        });
        return true
    }
    off = (evt, fn) => {
        if (!this._events[evt]) return
        if (!fn) {
            this._events[evt].length = 0
        } else {
            const fns = this._events[evt]
            for (let i = 0; i < fns.length; i++) {
                if (fn === fns[i]) {
                    fns.splcie(i, 1)
                    break
                }
            }
        }
    }
    removeAllListeners = (evt) => {
        if (evt) {
            this._events[evt] && (this._events[evt].length = 0)
        } else {
            this._events = []
        }
    }
}